#include <glib.h>

gint main(gint argc, gchar **argv)
{
    GByteArray *barr = NULL;
    GBytes *bytes = NULL;
    gconstpointer data = NULL;
    gsize size = 0;

    barr = g_byte_array_new ();
    g_byte_array_append (barr, (guint8 *)"Hello", 6);

    bytes = g_byte_array_free_to_bytes (barr);
    data = g_bytes_get_data (bytes, &size);
    g_print("size:%d, data:%s \n", (gint)size, (gchar *)data);

    g_bytes_unref (bytes);

    return 0;
}